import { Interceptors } from '@/plugins/request/interceptors'
import { AxiosRequestConfig } from 'ts-axios-new'

export class HttpServer {
  axios: any
  constructor() {
    this.axios = new Interceptors().getInterceptors()
  }
  request(config: AxiosRequestConfig): Promise<any> {
    return new Promise((resolve, reject) => {
      this.axios(config)
        .then((res: any) => {
          resolve(res)
        })
        .catch((err: any) => {
          reject(err)
        })
    })
  }
}

const http = new HttpServer()

export default http
